<?php
class front_job_announ extends Zcontroller{
	
    function __construct() {
   	    parent::__construct();
   	    //menu current page
		Zsession::setDataToSession("current_page", "job");		
    }
	
	public function index() {  
		$this->load->model("front_m_job");
       //$data["all_location"]=$this->front_m_job->get_all_locations();
        //$this->load->template("templates/general","jobs/job_view", "Zuka",$data);
    }
	function goto_job_page(){
    	$this->load->model("front_m_job");
    	$this->load->helper('url_helper');
    	$this->load->library('pagination');
    	$data =array();
    	$config=array();
    	$config['base_url'] = base_url().'index.php/front_job_announ/goto_job_page/';
    	$total_title=$this->front_m_job->count_all_title();
      	$config['total_rows'] = count($total_title->result());
      	$config['per_page'] = '10';
      	$config['full_tag_open'] = '<p>';
      	$config['full_tag_close'] = '</p>';
      	$this->pagination->initialize($config);
      	
      	$data['get_jobCat']=$this->front_m_job->get_jobCategory();
      	$data['all_location']=$this->front_m_job->get_all_job_location();
    	$data['all_announ']=$this->front_m_job->get_allannoun_front($config['per_page'],$this->uri->segment(3));
    	$this->load->template("templates/general","job_announ_front_end/job_view_front", "Job Announcement",$data);
    }
	function showcompanylogo($comid){
           $this->load->model("front_m_job");
           $result=$this->front_m_job->get_company_by_comid($comid);
           $image_content=pg_unescape_bytea($result['com_logo']);
           header("Content-type:".$result['com_logo_type']);
           print $image_content;
       }
    function view_job_by_company($comid){
    	$this->load->model("front_m_job");
    	$this->load->helper('url_helper');
    	$this->load->library('pagination');
    	$data =array();
    	$config=array();
    	$config['base_url'] = base_url().'index.php/front_job_announ/view_job_by_company/$comid';
    	$total_title=$this->front_m_job->count_all_title();
      	$config['total_rows'] = count($total_title->result());
      	$config['per_page'] = '10';
      	$config['full_tag_open'] = '<p>';
      	$config['full_tag_close'] = '</p>';
      	$this->pagination->initialize($config);
      	$data['all_cate']=$this->front_m_job->get_all_job_category();
      	$data['all_location']=$this->front_m_job->get_all_job_location();
    	$data['all_announ']=$this->front_m_job->get_allannoun_by_comid($comid,$config['per_page'],$this->uri->segment(4));
    	$this->load->template("templates/general","job_announ_front_end/job_by_company", "Job Announcement",$data);
    }
    function view_job_detail($announid){
    	$this->load->model("front_m_job");
    	$data=array();
    	$this->front_m_job->addnew_hit_job($announid);
    	$data['tableannoun']=$this->front_m_job->get_announ_by_announid($announid);
    	$data['tablecompany']=$this->front_m_job->get_company_by_comid($data['tableannoun']['com_id']);
    	$data['tabletitle']=$this->front_m_job->get_title_by_announid($announid);
    	//$data['tabletitle']=$this->front_m_job->get_title_by_announid($announid);
    	//$data['tablecategory']=$this->front_m_job->get_category_by_titleid($titleid);
    	//$data['tablelocation']=$this->front_m_job->get_location_by_titleid($titleid);
    	//$data['tablerequirement']=$this->front_m_job->get_requirement_by_titleid($titleid);
    	//$data['tableduty']=$this->front_m_job->get_duty_by_titleid($titleid);
    	//$data['tableschedule']=$this->front_m_job->get_schedule_by_titleid($titleid);
    	$this->load->template("templates/general","job_announ_front_end/job_detail", "Job Announcement",$data);
    }
    function search_job_result(){
    	$this->load->model("front_m_job");
    	$this->load->helper('url_helper');
    	$this->load->library('pagination');
    	$data =array();
    	$config=array();
    	$category=trim($_POST['cbocategory']);
    	$location=trim($_POST['cbolocation']);
    	$config['base_url'] = base_url().'index.php/front_job_announ/search_job_result/';
    	$total_title=$this->front_m_job->count_search_result($category,$location);
      	$config['total_rows'] = count($total_title->result());
      	$config['per_page'] = '10';
      	$config['full_tag_open'] = '<p>';
      	$config['full_tag_close'] = '</p>';
      	$this->pagination->initialize($config);
      	$data['all_cate']=$this->front_m_job->get_all_job_category();
      	$data['all_location']=$this->front_m_job->get_all_job_location();
    	$data['all_announ']=$this->front_m_job->search_job_result($category,$location,$config['per_page'],$this->uri->segment(3));
    	$this->load->template("templates/general","job_announ_front_end/job_view_front", "Job Announcement",$data);
    }
}
?>